//
//  DetailLabelTableViewCell.m
//  BTRIP
//
//  Created by johnbk on 15/11/16.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "DetailLabelTableViewCell.h"
#import "SuitableHeight.h"
@implementation DetailLabelTableViewCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(void)dealloc{
	[_labelOfDescription release];
	[_labelOfTitle release];
	
	[_detailSpecialSubModel release];
	[_arrayOfHeightOfDesc release];
	[super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
	self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
	if (self) {
		_arrayOfHeightOfDesc = [NSArray array];
		[self createView];
	}
	return self;
}
-(void)createView{
	self.labelOfTitle = [[UILabel alloc]init];

	
	self.labelOfDescription = [[UILabel alloc]init];
			[self.contentView addSubview:self.labelOfDescription];
			[self.labelOfDescription release];
			self.labelOfDescription.font = [UIFont systemFontOfSize:12];

}
- (void)layoutSubviews{
	[super layoutSubviews];
	self.labelOfTitle.frame = CGRectMake(20, 10, self.frame.size.width - 40, self.heightOfTitle);
	//self.labelOfTitle.backgroundColor = [UIColor greenColor];
	
	self.labelOfDescription.frame = CGRectMake(20, 10 + self.labelOfTitle.frame.size.height, self.labelOfTitle.frame.size.width, self.heightOfDescription);
	//self.labelOfDescription.backgroundColor = [UIColor redColor];
	self.labelOfDescription.numberOfLines = 0;
	self.labelOfDescription.lineBreakMode = NSLineBreakByWordWrapping;

	
}
+ (DetailLabelTableViewCell *)tableView:(UITableView *)tableView{
	static NSString *cellIdentifier = @"DetailLabelTableViewCellIdentifier";
	DetailLabelTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
	if (!cell) {
		cell = [[DetailLabelTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
	}
	return cell;
}
-(void)setDetailSpecialSubModel:(DetailSpecialSubModel *)detailSpecialSubModel{
	if (_detailSpecialSubModel != detailSpecialSubModel) {
		[_detailSpecialSubModel release];
		_detailSpecialSubModel = [detailSpecialSubModel retain];
		[self layoutSubviews];
		if (![detailSpecialSubModel.title isEqualToString:@""]) {
			[self.contentView addSubview:self.labelOfTitle];
			
			self.labelOfTitle.font = [UIFont systemFontOfSize:14];
			self.labelOfTitle.text = detailSpecialSubModel.title;
			self.heightOfTitle = 30;
		}else{
			self.heightOfTitle = 0;
		}
		
		self.heightOfDescription = [SuitableHeight suitableHeight:detailSpecialSubModel.desp andWidth:self.labelOfDescription.frame.size.width andFont:12];
		self.labelOfDescription.text = detailSpecialSubModel.desp;
		
		[self layoutSubviews];
		
		
		
		
	}
	
	

	
}
@end
